#include <iostream>
#include <string>
#include <stdio.h>

enum EnumApiTransState
{
    api_trans_state_undefined = -1,
    api_trans_state_idle,
    api_trans_state_server_request_recv,
    api_trans_state_server_final_resp_sent,
    api_trans_state_client_request_sent,
    api_trans_state_client_proceeding,
    api_trans_state_terminated,
    api_trans_state_client_final_resp_recv,
    api_trans_state_client_msg_send_failure
};

std::string transState2String(EnumApiTransState state)
{
#define TRANS_STATE_CASE(STATE) \
    case STATE:                 \
        return #STATE;

    switch (state)
    {
        TRANS_STATE_CASE(api_trans_state_undefined)
        TRANS_STATE_CASE(api_trans_state_idle)
        TRANS_STATE_CASE(api_trans_state_server_request_recv)
        TRANS_STATE_CASE(api_trans_state_server_final_resp_sent)
        TRANS_STATE_CASE(api_trans_state_client_request_sent)
        TRANS_STATE_CASE(api_trans_state_client_proceeding)
        TRANS_STATE_CASE(api_trans_state_terminated)
        TRANS_STATE_CASE(api_trans_state_client_final_resp_recv)
        TRANS_STATE_CASE(api_trans_state_client_msg_send_failure)
        default:
            break;
    }
    return "api_trans_state_undefined";
};

int main()
{
    EnumApiTransState state = static_cast<EnumApiTransState>(1);
    std::cout << transState2String(state) << std::endl;
}